<template>
  <div class="RecruitEdit">
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="80px"
      class="demo-ruleForm"
    >
      <el-row>
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <el-form-item label="招聘岗位" prop="post">
              <el-input v-model="form.post"></el-input>
            </el-form-item>

            <el-form-item label="专业要求" prop="major">
              <el-input v-model="form.major"></el-input>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="grid-content bg-purple-light">
            <el-form-item label="工资(K)" prop="salary">
              <el-input v-model="form.salary"></el-input>
            </el-form-item>

            <el-form-item label="招聘人数" prop="number">
              <el-input v-model="form.number"></el-input>
            </el-form-item>
          </div>
        </el-col>
      </el-row>

      <el-form-item label="工作内容" prop="content">
        <mavon-editor v-model="form.content"></mavon-editor>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit('from')">确认</el-button>
        <el-button @click="unSubmit">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "RecruitEdit",
  data() {
    return {
      id: this.$route.query.id,
      comID: "",
      form: {
        id: this.$route.query.id,
        comId: "",
        post: "",
        major: "",
        salary: "",
        number: "",
        content: "",
        reTime: "",
      },
      rules: {
        post: [{ required: true, message: "请输入岗位", trigger: "blur" }],
        major: [{ required: true, message: "请选择活动区域", trigger: "blur" }],
        salary: [{ required: true, message: "请输入工资", trigger: "blur" }],
        number: [
          { required: true, message: "请输入招聘人数", trigger: "blur" },
        ],
        content: [
          { required: true, message: "请输入工作内容", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    const comid = this.$store.getters.getCompany.id;
    this.comID = comid;
    //console.log("comID:" + this.comID);
    const id = this.id;
    if (id != null) {
      this.page(id);
    }
  },
  methods: {
    page(id) {
      const _this = this;
      _this.$axios.get("/queryRecruit/" + id).then((res) => {
        console.log(res);
        _this.form = res.data.data;
      });
    },

    onSubmit() {
      //const _this = this;
      const comID = this.comID;
      console.log("comID:" + comID);
      this.form.comId = comID;
      this.form.reTime = "";
      console.log("comID2:" + this.form.comId);

      this.$axios.post("/recruitEdit", this.form).then((res) => {
        console.log(res);
        this.$message({
          message: "操作成功",
          type: "success",
        });
        this.$router.push("/company/rInformation");
      });
    },

    unSubmit() {
      this.$router.push("/company/rInformation");
    },
  },
};
</script>

<style scoped>
.comEdit {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 0px auto;
  /*  width: 500px;*/
  padding: 15px 30px 15px 30px;
  background-color: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}
.loginTitle {
  margin: 0px auto 40px auto;
  text-align: center;
}
</style>
